<?php
class CDailyReport
{
	public function __construct()
	{
		$now = getdate();	
		$today = date('dmY', mktime($now['mon'], $now['mday'], $now['year']));
		$this->_filename	= ROOT_SITE.'/data/dailyreport';
		@mkdir($this->_filename);
		$this->_filename	= $this->_filename.'/dailyreport_' . $today ;
	}
	
	public function save($strContent)
	{
		@file_put_contents($this->_filename .'.html', $strContent);
		@file_put_contents($this->_filename .'.xls', $strContent);
	}
	
	public function get($p_day)
	{
		$filename	= ROOT_SITE.'/data/dailyreport/dailyreport_' . $p_day . '.html';
		$strContent	= @file_get_contents($filename);
		return $strContent ? $strContent : null;
	}
	
	public function saveViewOrder($strContent, $filename, $type)
	{
		$filenamexls =   ROOT_SITE.'/data/dailyreport/' . $filename .'_'. $type .'.xls';
		$filenamehtml =  ROOT_SITE.'/data/dailyreport/' . $filename .'_'. $type .'.html';
		@file_put_contents($filenamexls, $strContent);
		@file_put_contents($filenamehtml, $strContent);
	}
	
	public function getViewOrder($filename)
	{
		$filename	=  ROOT_SITE.'/data/dailyreport/' . $filename . '.html';
		$strContent	= @file_get_contents($filename);
		return $strContent ? $strContent : null;
	}
}
?>